using SurveySez.Model;
using SurveySez.NavigationModel;

namespace SurveySez.ViewModel.Editor
{
	public class AnswerViewModel
	{
		private int _index;
		private Response _response;
		private GameNavigation _gameNavigation;

		public AnswerViewModel(int index, Response response, GameNavigation gameNavigation)
		{
			_index = index;
			_response = response;
			_gameNavigation = gameNavigation;
		}

		public string Display
		{
			get { return string.Format("{0} - {1}", _index + 1, _response.Answer); }
		}

		public bool IsPending
		{
			get { return _gameNavigation.CurrentRound.IsAnswerPending(_response); }
		}

		public bool IsGuessed
		{
			get { return _gameNavigation.CurrentRound.IsAnswerGuessed(_response); }
		}

		public override bool Equals(object obj)
		{
			if (obj == this)
				return true;
			AnswerViewModel that = obj as AnswerViewModel;
			if (that == null)
				return false;
			return _response == that._response;
		}

		public override int GetHashCode()
		{
			return _response.GetHashCode();
		}
	}
}
